netfilter: nf_tables: fix memleak when more than 255 elements expired
authorSasha Levin <sashal@kernel.org>
Fri, 22 Sep 2023 16:30:29 +0000 (18:30 +0200)
committerSalvatore Bonaccorso <carnil@debian.org>
Fri, 29 Sep 2023 04:15:31 +0000 (05:15 +0100)
commitfe63f2506659b99094675f7ca61907f20510ff2c
tree177f9d8c9e20b5f07b7cc982dad0911fbd44ef4c
parent9161742ca651b5c3adfe9a721e2ccec9a0640ac1
netfilter: nf_tables: fix memleak when more than 255 elements expired

commit cf5000a7787cbc10341091d37245a42c119d26c5 upstream.

When more than 255 elements expired we're supposed to switch to a new gc
container structure.

This never happens: u8 type will wrap before reaching the boundary
and nft_trans_gc_space() always returns true.

This means we recycle the initial gc container structure and
lose track of the elements that came before.

While at it, don't deref 'gc' after we've passed it to call_rcu.

Fixes: 5f68718b34a5 ("netfilter: nf_tables: GC transaction API to avoid race with control plane")
Reported-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name netfilter-nf_tables-fix-memleak-when-more-than-255-e.patch
include/net/netfilter/nf_tables.h
net/netfilter/nf_tables_api.c